package com.macrounion.atv.service.entity.ext;

import com.macrounion.atv.service.entity.CurrentData;

public class CurrentDataExt extends CurrentData implements Comparable<CurrentDataExt> {

    private static final long serialVersionUID = -6923306032991975231L;

    private String deviceName;
    private String spotName;
    private String channelName;
    private String spotParentId;

    public String getSpotParentId() {
        return spotParentId;
    }

    public void setSpotParentId(String spotParentId) {
        this.spotParentId = spotParentId;
    }

    private Integer dataType;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getSpotName() {
        return spotName;
    }

    public void setSpotName(String spotName) {
        this.spotName = spotName;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }

    public Integer getDataType() {
        return dataType;
    }

    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }

    @Override
    public int compareTo(CurrentDataExt o) {
        String oChannelCode = o.getChannelCode();
        String thisChannelCode = this.getChannelCode();
        if (oChannelCode == null) {
            oChannelCode = "";
        }
        if (thisChannelCode == null) {
            thisChannelCode = "";
        }
        if (oChannelCode.startsWith("t")) {
            oChannelCode = oChannelCode.substring(1);
        }
        if (thisChannelCode.startsWith("t")) {
            thisChannelCode = thisChannelCode.substring(1);
        }
        if (!thisChannelCode.equals(oChannelCode)) {
            return Integer.parseInt(thisChannelCode) - Integer.parseInt(oChannelCode);
        } else {
            return this.getUpdateTime().compareTo(o.getUpdateTime());
        }
    }
}
